<template>
  <div class="app-container">
    <el-table
      ref="table"
      :key="tableKey"
      v-loading="loading"
      :data="list"
      border
      fit
      style="width: 100%;"
      :highlight-current-row="true"
    >
      <el-table-column label="屏幕编码" prop="menuId" :show-overflow-tooltip="true" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.menuId }}</span>
        </template>
      </el-table-column>
      <el-table-column label="屏幕名称" prop="menuName" :show-overflow-tooltip="true" align="center" min-width="100px">
        <template slot-scope="scope">
          <span>{{ scope.row.menuName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" prop="createTime" :show-overflow-tooltip="true" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" prop="type" :show-overflow-tooltip="true" align="center" min-width="180px">
        <template>
          <span>生效</span>
        </template>
      </el-table-column>
      <el-table-column label="屏幕尺寸" :show-overflow-tooltip="true" align="center" min-width="180px">
        <template>
          <span>1920*1080</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('table.operation')" align="center" min-width="150px" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="{row}">
          <i class="el-icon-setting table-operation" style="color: #2db7f5;" @click="view(row)" />
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="pagination.num" :limit.sync="pagination.size" @pagination="fetch" />
  </div>
</template>
<script>
import Pagination from '@/components/Pagination';

export default {
  name: 'DataScreen',
  components: { Pagination },
  filters: {},
  data() {
    return {
      dialog: {
        isVisible: false,
        title: '',
        type: ''
      },
      tableKey: 0,
      loading: false,
      list: null,
      total: 0,
      queryParams: {},
      pagination: {
        size: 10,
        num: 1
      }
    };
  },
  mounted() {
    this.fetch();
  },
  methods: {
    search() {
      this.fetch({
        ...this.queryParams
      });
    },
    reset() {
      this.queryParams = {};
      this.search();
    },
    fetch(params = {}) {
      params.pageSize = this.pagination.size;
      params.pageNum = this.pagination.num;
      this.loading = true;
      this.$get('system/menu/datascreen', {
        ...params
      }).then(r => {
        const data = r.data.resultBody;
        this.total = data.total;
        this.list = data.records;
        this.loading = false;
      });
    },
    view() {
      alert(window.location.href);
      var url = '/datascreen/view'
      window.open(url, '_blank');
    }
  }
};
</script>
<style lang="scss" scoped>
</style>
